<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>动态时钟</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #282c34;
            margin: 0;
        }
        #clock {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            color: #61dafb;
            font-size: 60px;
            background-color: #1e1f26;
            padding: 20px 40px;
            border-radius: 10px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
        }
    </style>
</head>
<body>

    <div id="clock">00:00:00</div>

    <script>
        // 获取时钟元素
        const clockElement = document.getElementById('clock');

        // 更新时钟函数
        function updateClock() {
            const now = new Date();

            let hours = now.getHours();
            let minutes = now.getMinutes();
            let seconds = now.getSeconds();

            // 补零函数
            hours = hours < 10 ? '0' + hours : hours;
            minutes = minutes < 10 ? '0' + minutes : minutes;
            seconds = seconds < 10 ? '0' + seconds : seconds;

            // 格式化时间字符串
            const currentTime = `${hours}:${minutes}:${seconds}`;

            // 更新时钟显示
            clockElement.textContent = currentTime;
        }

        // 初始调用以避免延迟
        updateClock();

        // 每秒更新一次时钟
        setInterval(updateClock, 1000);
    </script>

</body>
</html>